﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetDocumentProjectID]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetDocumentProjectID];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetDocumentProjectID]
    @DocID int
AS
IF EXISTS(SELECT 1 FROM uds_flow_document WHERE doc_id = @docid AND OBJ_TYPE = 2 )
BEGIN
    DECLARE @ProjectID int
    SELECT     @ProjectID =  Obj_ID 
        FROM 
            uds_flow_document 
        WHERE     doc_id = @docid 
            AND OBJ_TYPE = 2 
    RETURN     @ProjectID
END
ELSE
    RETURN     0